package org.dreamwork.peony;

import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.DecimalFormat;

/**
 * Created by IntelliJ IDEA.
 * User: seth
 * Date: 2009-8-25
 * Time: 15:57:08
 */
public class Formatter {
    public static String format (Object value, String pattern) {
        if (value == null) return "";
        if (value instanceof Date) {
            return new SimpleDateFormat (pattern).format (value);
        } else if (value instanceof Number) {
            return new DecimalFormat (pattern).format (value);
        }

        return value.toString ();
    }
}